<?php  include VIEWPATH.'common/head.php';  ?>
    <script type="text/javascript">
        var status = '<?php echo $_GET['status'];?>';
        if(status == '-1'){
            alert('fail:<?php echo $_GET['msg'];?>');
        }
        function setJinList(type){
            var ids = document.getElementsByName('uid[]');
            var sel_ids = '';
            for (var i = 0; i < ids.length; i++){
                if (ids[i].checked) {
                    sel_ids += ids[i].value + ',';
                }
            }
            if(sel_ids === ''){
                alert('请选择要操作的用户');
                return;
            }
            sel_ids = sel_ids.substr(0,sel_ids.length - 1);
            if(sel_ids === ''){
                alert('请选择要操作的用户');
                return ;
            }
            $("#user_ids").val(sel_ids);
            $("#type").val(type);
            if(type === 4){
                $("#punish_type").html("禁言");
            }else if(type === 5){
                $("#punish_type").html("禁闭");
            }else if(type === 6){
                $("#punish_type").html("封号");
            }
            $('#user_jin').modal('show');
        }
        function jia_v(uid, is_v){
            if(!confirm("你确认此操作吗？")){
                return false;
            }
            var url = "index.php?c=user&m=jia_v";
            var param = {"uid":uid, "is_v":is_v};
            common_ajax(url, param, function(data){
                if(data.errorCode == 0) {
                    window.location.href=  window.location.href;
                    return true;
                }else{
                    alert(data.errorMsg);
                }
            });
        }
        function on_submit(){
            var time_range = $("#time_range").val();
            if(!time_range || time_range === "0"){
                alert("请选择禁止时间");
                return false;
            }
            $("#jin_form").submit();
        }
        $("#user_jin").on("hidden.bs.modal", function() {
            $(this).removeData("bs.modal");
        });
    </script>

    <body class="gray-bg">
    <div class="wrapper wrapper-content">


        <div class="add-btn" style="float:right;margin-bottom:5px;">
            <div class="modal fade" id="user_edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
                <div class="modal-dialog" style="width: 60%;"><div class="modal-content"></div></div>
            </div>
        </div>

        <div class="add-btn" style="float:right;margin-bottom:5px;">
            <div class="modal fade" id="add_img" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
                <div class="modal-dialog" style="width: 60%;"><div class="modal-content"></div></div>
            </div>
        </div>
        <div class="modal fade" id="user_jin" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
            <div class="modal-dialog" style="width: 50%;">
                <div class="modal-content">
                    <div class="tab-pane active" id="horizontal-form">

                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                            <h2 class="modal-title">处理用户</h2>
                        </div>
                        <form class="form-horizontal" id="jin_form" action="index.php?c=user&m=user_jin" name="form" method="post">
                            <input type="hidden" name="user_ids" id="user_ids" value=""/>
                            <input type="hidden" name="type" id="type" value=""/>
                            <input type="hidden" name="submits" value="1"/>

                            <div class="form-group">
                                <label for="pubish_type" class="col-sm-2 control-label">操作类型</label>
                                <div class="col-sm-3" id="punish_type"></div>
                            </div>
                            <div class="form-group">
                                <label for="time_range" class="col-sm-2 control-label">禁止时间</label>
                                <div class="col-sm-3">
                                    <select name="time_range" id="time_range" class="form-control">
                                        <option value="0">请选择</option>
                                        <option value="1">30分钟</option>
                                        <option value="2">一小时</option>
                                        <option value="3">24小时</option>
                                        <option value="7">3天</option>
                                        <option value="4">7天</option>
                                        <option value="5">永久</option>
                                        <option value="6">解除</option>
                                    </select>
                                </div>
                            </div>

                            <div class="modal-footer">
                                <button type="reset" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <button type="button" onclick="on_submit()" class="btn btn-primary">保存</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <div class="clearfix"></div>
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <form class="form-horizontal" id="f_form" action="index.php?c=<?php echo $_REQUEST['c'];?>&m=<?php echo $_REQUEST['m'];?>" name="form" method="post">
                            <div class="form-group">
                                <div class="col-sm-1 text-right"><label class="control-label">用户类型：</label></div>
                                <div class="col-sm-2">
                                    <select name="user_type" class="form-control">
                                        <option value=""  <?php echo empty($_REQUEST["user_type"]) ? "selected" : ""?> >全部</option>
                                        <option value="1" <?php echo $_REQUEST["user_type"]==1?"selected":""?> >注册用户</option>
                                        <option value="2" <?php echo $_REQUEST["user_type"]==2?"selected":""?> >机器人</option>
                                        <option value="3" <?php echo $_REQUEST["user_type"]==3?"selected":""?> >导入用户</option>
                                        <option value="4" <?php echo $_REQUEST["user_type"]==4?"selected":""?> >签约用户</option>
                                    </select>
                                </div>
                                <div class="col-sm-1 text-right"><label class="control-label">用户状态：</label></div>
                                <div class="col-sm-2">
                                    <select name="user_status" class="form-control">
                                        <option value=""  <?php echo empty($_REQUEST["user_status"])?"selected" : ""?> >全部</option>
                                        <option value="4" <?php echo $_REQUEST["user_status"]==4?"selected":""?> >禁言</option>
                                        <option value="5" <?php echo $_REQUEST["user_status"]==5?"selected":""?> >禁闭</option>
                                        <option value="6" <?php echo $_REQUEST["user_status"]==6?"selected":""?> >封号</option>
                                    </select>
                                </div>
                                <div class="col-sm-1 text-right"><label class="control-label">手机号：</label></div>
                                <div class="col-sm-2">
                                    <input type="text" placeholder="请输入手机号" class="form-control" value="<?php echo $_REQUEST["mobile"];?>" name="mobile" autocomplete="off"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-1 text-right"><label class="control-label">用户来源：</label></div>
                                <div class="col-sm-2">
                                    <select name="user_source" class="form-control">
                                        <option value=""  <?php echo empty($_REQUEST["user_source"]) ? "selected" : ""?> >全部</option>
                                        <?php foreach($sourceList as $source){ ?>
                                            <option value="<?php echo $source["user_source"];?>"<?php echo $_REQUEST["user_source"] == $source["user_source"] ? "selected" : ""?> ><?php echo $source["user_source"];?></option>
                                        <?php } ?>
                                    </select>
                                </div>
                                <div class="col-sm-1 text-right"><label class="control-label">排序：</label></div>
                                <div class="col-sm-2">
                                    <select name="order_by" class="form-control">
                                        <option value="regdate"  <?php echo empty($_REQUEST["order_by"]) ? "selected" : ""?> >默认(注册时间)</option>
                                        <option value="last_login" <?php echo $_REQUEST["order_by"]=='last_login'?"selected":""?> >登录时间</option>
                                    </select>
                                </div>
                                <div class="col-sm-1">
                                    <button class="btn btn-sm btn-primary" type="submit"> 搜索 </button>
                                </div>
                            </div>

                            <table class="table table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <th></th>
                                        <th>ID</th>
                                        <th>昵称</th>
                                        <th>登录方式</th>
                                        <th>性别</th>
                                        <th>手机号</th>
                                        <th>城市</th>
                                        <th>注册日期</th>
                                        <th>用户类别</th>
                                        <th>用户来源</th>
                                        <th>获取点赞数</th>
                                        <th>粉丝数量</th>
                                        <th>关注数</th>
                                        <th>帖子数</th>
                                        <th></th>
                                    </tr>
                                </thead>
                                <tbody>
                                <?php
                                $loginType = array(1=>"手机号", 2=>"QQ", 3=>"微信", 4=>"微博");$sexArr = array(0=>"默认", 1=>"男", 2=>"女");
                                $userType = array(1=>"注册用户", 2=>"机器人", 3=>"数据导入", 4=>"签约用户");
                                foreach($userList as $user) {
                                        $userCoun = $this->UserCount->query_one(array("uid"=>$user["uid"]));
                                    ?>
                                    <tr>
                                        <th scope="row">
                                            <input type="checkbox" name="uid[]" value="<?php echo $user['uid']; ?>" class="checkbox ck" />
                                        </th>
                                        <td><?php echo $user['uid']; ?></td>
                                        <td nowrap="nowrap" title="<?php echo $user['nickname'];?>">

                                            <a  class="J_menuItem" data-names="用户详情"  href="index.php?c=user&m=user_info&&uid=<?php echo $user["uid"]; ?>&op=user_info" target="_blank">
                                                <?php echo mb_substr($user['nickname'],0, 10, "UTF-8")."..."; ?>
                                            </a>
                                        </td>
                                        <td nowrap="nowrap"><?php echo $loginType[$user['login_type']]; ?></td>
                                        <td nowrap="nowrap"><?php echo $sexArr[$user['sex']]; ?></td>
                                        <td nowrap="nowrap"><?php echo $user['mobile']; ?></td>
                                        <td><?php echo $this->DistrictModel->getCityName($user['city_id']); ?></td>
                                        <td><?php echo !empty($user['regdate']) ? date("Y-m-d H:i", $user['regdate']) : ""; ?></td>
                                        <td><?php echo $userType[$user['user_type']]; ?></td>
                                        <td nowrap="nowrap"><?php echo $user['user_source']; ?></td>
                                        <td><?php echo $userCoun['like_num']; ?></td>
                                        <td><?php echo $userCoun['fans_num']; ?></td>
                                        <td><?php echo $userCoun['follow_num']; ?></td>
                                        <td><?php echo $userCoun['pub_num']; ?></td>
                                        <td nowrap="nowrap">
                                            <a href="index.php?c=user&m=user_update&uid=<?php echo $user["uid"]; ?>" data-toggle="modal" data-target="#user_edit">编辑</a>
                                            <?php if($user["is_v"]){ ?>
                                                <a href="javascript:void(0)" onclick="jia_v(<?php echo $user["uid"]; ?>, 0)">取消加V</a>
                                            <?php }else{ ?>
                                                <a href="javascript:void(0)" onclick="jia_v(<?php echo $user["uid"]; ?>, 1)">加 V</a>
                                            <?php } ?>
                                        </td>
                                    </tr>
                                <?php }?>
                                </tbody>
                            </table>
                            <div class="set_page">
                                <?php echo $multipage;?>
                                <div class="set_del">
                                    <label class="l_c_sel">
                                        <input type="checkbox" name="chkall" onclick="checkAll('prefix', this.form, 'uid')" class="checkbox c_sel" style="float: left;margin: 0px;display: inline;"/>全选
                                    </label>
                                    <a href="javascript:void(0)" onclick="setJinList(4)">禁言</a>
                                    <a href="javascript:void(0)" onclick="setJinList(5)">禁闭</a>
                                    <a href="javascript:void(0)" onclick="setJinList(6)">封号</a>
                                </div>
                                <div class="clearfix"></div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <script src="http://gosspublic.alicdn.com/aliyun-oss-sdk-4.4.4.min.js"></script>
    <script>

    </script>

<?php  include VIEWPATH.'common/footer.php';  ?>